home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-10-31 | 55.3 KB | 1,710 lines |
- Newsgroups: comp.sources.misc
- From: daveg@synaptics.com (David Gillespie)
- Subject: v24i066: gnucalc - GNU Emacs Calculator, v2.00, Part18/56
- Message-ID: <1991Oct31.072543.17772@sparky.imd.sterling.com>
- X-Md4-Signature: af147e014f18196725b5e8bb4046407b
- Date: Thu, 31 Oct 1991 07:25:43 GMT
- Approved: kent@sparky.imd.sterling.com
-
- Submitted-by: daveg@synaptics.com (David Gillespie)
- Posting-number: Volume 24, Issue 66
- Archive-name: gnucalc/part18
- Environment: Emacs
- Supersedes: gmcalc: Volume 13, Issue 27-45
-
- ---- Cut Here and unpack ----
- #!/bin/sh
- # this is Part.18 (part 18 of a multipart archive)
- # do not concatenate these parts, unpack them in order with /bin/sh
- # file calc-graph.el continued
- #
- if test ! -r _shar_seq_.tmp; then
- echo 'Please unpack part 1 first!'
- exit 1
- fi
- (read Scheck
- if test "$Scheck" != 18; then
- echo Please unpack part "$Scheck" next!
- exit 1
- else
- exit 0
- fi
- ) < _shar_seq_.tmp || exit 1
- if test ! -f _shar_wnt_.tmp; then
- echo 'x - still skipping calc-graph.el'
- else
- echo 'x - continuing file calc-graph.el'
- sed 's/^X//' << 'SHAR_EOF' >> 'calc-graph.el' &&
- X (or (>= calc-gnuplot-version 3)
- X (insert cmd))
- X (set-marker (process-mark calc-gnuplot-process) (point))
- X (process-send-string calc-gnuplot-process cmd)
- X (if (get-buffer-window calc-gnuplot-buffer)
- X (calc-graph-view-trail))
- X (accept-process-output (and (not calc-graph-no-wait)
- X calc-gnuplot-process))
- X (calc-gnuplot-check-for-errors)
- X (if (get-buffer-window calc-gnuplot-buffer)
- X (calc-graph-view-trail))))
- )
- (setq calc-graph-no-wait nil)
- X
- (defun calc-graph-init-buffers ()
- X (or (and calc-gnuplot-buffer
- X (buffer-name calc-gnuplot-buffer))
- X (setq calc-gnuplot-buffer (get-buffer-create "*Gnuplot Trail*")))
- X (or (and calc-gnuplot-input
- X (buffer-name calc-gnuplot-input))
- X (setq calc-gnuplot-input (get-buffer-create "*Gnuplot Commands*")))
- )
- X
- (defun calc-graph-init ()
- X (or (calc-gnuplot-alive)
- X (let ((process-connection-type t)
- X origin)
- X (if calc-gnuplot-process
- X (progn
- X (delete-process calc-gnuplot-process)
- X (setq calc-gnuplot-process nil)))
- X (calc-graph-init-buffers)
- X (save-excursion
- X (set-buffer calc-gnuplot-buffer)
- X (insert "\nStarting gnuplot...\n")
- X (setq origin (point)))
- X (setq calc-graph-last-device nil)
- X (setq calc-graph-last-output nil)
- X (condition-case err
- X (let ((args (append (and calc-gnuplot-display
- X (not (equal calc-gnuplot-display
- X (getenv "DISPLAY")))
- X (list "-display"
- X calc-gnuplot-display))
- X (and calc-gnuplot-geometry
- X (list "-geometry"
- X calc-gnuplot-geometry)))))
- X (setq calc-gnuplot-process
- X (apply 'start-process
- X "gnuplot"
- X calc-gnuplot-buffer
- X calc-gnuplot-name
- X args))
- X (process-kill-without-query calc-gnuplot-process))
- X (file-error
- X (error "Sorry, can't find \"%s\" on your system."
- X calc-gnuplot-name)))
- X (save-excursion
- X (set-buffer calc-gnuplot-buffer)
- X (while (and (not (save-excursion
- X (goto-char origin)
- X (search-forward "gnuplot> " nil t)))
- X (memq (process-status calc-gnuplot-process) '(run stop)))
- X (accept-process-output calc-gnuplot-process))
- X (or (memq (process-status calc-gnuplot-process) '(run stop))
- X (error "Unable to start GNUPLOT process."))
- X (if (save-excursion
- X (goto-char origin)
- X (re-search-forward
- X "G N U P L O T.*\n.*version \\([0-9]+\\)\\." nil t))
- X (setq calc-gnuplot-version (string-to-int (buffer-substring
- X (match-beginning 1)
- X (match-end 1))))
- X (setq calc-gnuplot-version 1))
- X (goto-char (point-max)))))
- X (save-excursion
- X (set-buffer calc-gnuplot-input)
- X (if (= (buffer-size) 0)
- X (insert "# Commands for running gnuplot\n\n\n")
- X (or calc-graph-no-auto-view
- X (eq (char-after (1- (point-max))) ?\n)
- X (progn
- X (goto-char (point-max))
- X (insert "\n")))))
- )
- X
- SHAR_EOF
- echo 'File calc-graph.el is complete' &&
- chmod 0644 calc-graph.el ||
- echo 'restore of calc-graph.el failed'
- Wc_c="`wc -c < 'calc-graph.el'`"
- test 47114 -eq "$Wc_c" ||
- echo 'calc-graph.el: original size 47114, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= calc-help.el ==============
- if test -f 'calc-help.el' -a X"$1" != X"-c"; then
- echo 'x - skipping calc-help.el (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting calc-help.el (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'calc-help.el' &&
- ;; Calculator for GNU Emacs, part II [calc-help.el]
- ;; Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- ;; Written by Dave Gillespie, daveg@csvax.cs.caltech.edu.
- X
- ;; This file is part of GNU Emacs.
- X
- ;; GNU Emacs is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY. No author or distributor
- ;; accepts responsibility to anyone for the consequences of using it
- ;; or for whether it serves any particular purpose or works at all,
- ;; unless he says so in writing. Refer to the GNU Emacs General Public
- ;; License for full details.
- X
- ;; Everyone is granted permission to copy, modify and redistribute
- ;; GNU Emacs, but only under the conditions described in the
- ;; GNU Emacs General Public License. A copy of this license is
- ;; supposed to have been given to you along with GNU Emacs so you
- ;; can know your rights and responsibilities. It should be in a
- ;; file named COPYING. Among other things, the copyright notice
- ;; and this notice must be preserved on all copies.
- X
- X
- X
- ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
- X
- (require 'calc-macs)
- X
- (defun calc-Need-calc-help () nil)
- X
- X
- (defun calc-help-prefix (arg)
- X "This key is the prefix for Calc help functions. See calc-help-for-help."
- X (interactive "P")
- X (or calc-dispatch-help (sit-for echo-keystrokes))
- X (let ((key (calc-read-key-sequence
- X (if calc-dispatch-help
- X "Calc Help options: Help, Info, Tutorial, Summary; Key, Function; ?=more"
- X (format "%s (Type ? for a list of Calc Help options)"
- X (key-description (this-command-keys))))
- X calc-help-map)))
- X (setq key (lookup-key calc-help-map key))
- X (message "")
- X (if key
- X (call-interactively key)
- X (beep)))
- )
- X
- (defun calc-help-for-help (arg)
- X "You have typed `h', the Calc help character. Type a Help option:
- X
- B calc-describe-bindings. Display a table of all key bindings.
- H calc-full-help. Display all `?' key messages at once.
- X
- I calc-info. Read the Calc manual using the Info system.
- T calc-tutorial. Read the Calc tutorial using the Info system.
- S calc-info-summary. Read the Calc summary using the Info system.
- X
- C calc-describe-key-briefly. Look up the command name for a given key.
- K calc-describe-key. Look up a key's documentation in the manual.
- F calc-describe-function. Look up a function's documentation in the manual.
- V calc-describe-variable. Look up a variable's documentation in the manual.
- X
- N calc-view-news. Display Calc history of changes.
- X
- C-c Describe conditions for copying Calc.
- C-d Describe how you can get a new copy of Calc or report a bug.
- C-w Describe how there is no warranty for Calc."
- X (interactive "P")
- X (if calc-dispatch-help
- X (let (key)
- X (save-window-excursion
- X (describe-function 'calc-help-for-help)
- X (select-window (get-buffer-window "*Help*"))
- X (while (progn
- X (message "Calc Help options: Help, Info, ... press SPC, DEL to scroll, C-g to cancel")
- X (memq (setq key (read-char)) '(? ?\C-h ?\C-? ?\C-v ?\M-v)))
- X (condition-case err
- X (if (memq key '(? ?\C-v))
- X (scroll-up)
- X (scroll-down))
- X (error (beep)))))
- X (setq unread-command-char key)
- X (calc-help-prefix nil))
- X (let ((calc-dispatch-help t))
- X (calc-help-prefix arg)))
- )
- X
- (defun calc-describe-copying ()
- X (interactive)
- X (calc-info)
- X (Info-goto-node "Copying")
- )
- X
- (defun calc-describe-distribution ()
- X (interactive)
- X (calc-info)
- X (Info-goto-node "Reporting Bugs")
- )
- X
- (defun calc-describe-no-warranty ()
- X (interactive)
- X (calc-info)
- X (Info-goto-node "Copying")
- X (let ((case-fold-search nil))
- X (search-forward " NO WARRANTY"))
- X (beginning-of-line)
- X (recenter 0)
- )
- X
- (defun calc-describe-bindings ()
- X (interactive)
- X (describe-bindings)
- X (save-excursion
- X (set-buffer "*Help*")
- X (goto-char (point-min))
- X (if (search-forward "Global bindings:" nil t)
- X (delete-region (match-beginning 0) (point-max)))
- X (goto-char (point-min))
- X (while (re-search-forward "\n[a-z] ESC" nil t)
- X (end-of-line)
- X (delete-region (match-beginning 0) (point)))
- X (goto-char (point-min))
- X (while (re-search-forward "\nESC m" nil t)
- X (end-of-line)
- X (delete-region (match-beginning 0) (point)))
- X (goto-char (point-min))
- X (while (search-forward "\n\n\n" nil t)
- X (backward-delete-char 1)
- X (backward-char 2))
- X (goto-char (point-min))
- X (while
- X (re-search-forward
- X "\n[a-z] [0-9]\\(\t\t.*\n\\)\\([a-z] [0-9]\\1\\)*[a-z] \\([0-9]\\)\\1"
- X nil t)
- X (let ((dig1 (char-after (1- (match-beginning 1))))
- X (dig2 (char-after (match-beginning 3))))
- X (delete-region (match-end 1) (match-end 0))
- X (goto-char (match-beginning 1))
- X (delete-backward-char 1)
- X (delete-char 1)
- X (insert (format "%c .. %c" (min dig1 dig2) (max dig1 dig2)))))
- X (goto-char (point-min)))
- )
- X
- (defun calc-describe-key-briefly (key)
- X (interactive "kDescribe key briefly: ")
- X (calc-describe-key key t)
- )
- X
- (defun calc-describe-key (key &optional briefly)
- X (interactive "kDescribe key: ")
- X (let ((defn (if (eq (key-binding key) 'calc-dispatch)
- X (let ((key2 (calc-read-key-sequence
- X (format "Describe key briefly: %s-"
- X (key-description key))
- X calc-dispatch-map)))
- X (setq key (concat key key2))
- X (lookup-key calc-dispatch-map key2))
- X (if (eq (key-binding key) 'calc-help-prefix)
- X (let ((key2 (calc-read-key-sequence
- X (format "Describe key briefly: %s-"
- X (key-description key))
- X calc-help-map)))
- X (setq key (concat key key2))
- X (lookup-key calc-help-map key2))
- X (key-binding key))))
- X (inv nil)
- X (hyp nil))
- X (while (or (equal key "I") (equal key "H"))
- X (if (equal key "I")
- X (setq inv (not inv))
- X (setq hyp (not hyp)))
- X (setq key (read-key-sequence (format "Describe key%s:%s%s "
- X (if briefly " briefly" "")
- X (if inv " I" "")
- X (if hyp " H" "")))
- X defn (key-binding key)))
- X (let ((desc (key-description key))
- X target)
- X (if (string-match "^ESC " desc)
- X (setq desc (concat "M-" (substring desc 4))))
- X (while (string-match "^M-# \\(ESC \\|C-\\)" desc)
- X (setq desc (concat "M-# " (substring desc (match-end 0)))))
- X (if briefly
- X (let ((msg (save-excursion
- X (set-buffer (get-buffer-create "*Calc Summary*"))
- X (if (= (buffer-size) 0)
- X (progn
- X (message "Reading Calc summary from manual...")
- X (save-window-excursion
- X (save-excursion
- X (calc-info)
- X (Info-goto-node "Summary")
- X (goto-char (point-min))
- X (forward-line 1)
- X (copy-to-buffer "*Calc Summary*"
- X (point) (point-max))
- X (Info-last)))
- X (setq case-fold-search nil)
- X (re-search-forward "^\\(.*\\)\\[\\.\\. a b")
- X (setq calc-summary-indentation
- X (- (match-end 1) (match-beginning 1)))))
- X (goto-char (point-min))
- X (setq target (if (and (string-match "[0-9]\\'" desc)
- X (not (string-match "[d#]" desc)))
- X (concat (substring desc 0 -1) "0-9")
- X desc))
- X (if (re-search-forward
- X (format "\n%s%s%s%s[ a-zA-Z]"
- X (make-string (+ calc-summary-indentation 9)
- X ?\.)
- X (if (string-match "M-#" desc) " "
- X (if inv
- X (if hyp "I H " " I ")
- X (if hyp " H " " ")))
- X (regexp-quote target)
- X (make-string (max (- 6 (length target)) 0)
- X ?\ ))
- X nil t)
- X (let (pt)
- X (beginning-of-line)
- X (forward-char calc-summary-indentation)
- X (setq pt (point))
- X (end-of-line)
- X (buffer-substring pt (point)))))))
- X (if msg
- X (let ((args (substring msg 0 9))
- X (keys (substring msg 9 19))
- X (prompts (substring msg 19 38))
- X (notes "")
- X (cmd (substring msg 40))
- X msg)
- X (if (string-match "\\` +" args)
- X (setq args (substring args (match-end 0))))
- X (if (string-match " +\\'" args)
- X (setq args (substring args 0 (match-beginning 0))))
- X (if (string-match "\\` +" keys)
- X (setq keys (substring keys (match-end 0))))
- X (if (string-match " +\\'" keys)
- X (setq keys (substring keys 0 (match-beginning 0))))
- X (if (string-match " [0-9,]+\\'" prompts)
- X (setq notes (substring prompts (1+ (match-beginning 0)))
- X prompts (substring prompts 0 (match-beginning 0))))
- X (if (string-match " +\\'" prompts)
- X (setq prompts (substring prompts 0 (match-beginning 0))))
- X (if (string-match "\\` +" prompts)
- X (setq prompts (substring prompts (match-end 0))))
- X (setq msg (format
- X "%s: %s%s`%s'%s%s %s%s"
- X (if (string-match
- X "\\`\\(calc-[-a-zA-Z0-9]+\\) *\\(.*\\)\\'"
- X cmd)
- X (prog1 (math-match-substring cmd 1)
- X (setq cmd (math-match-substring cmd 2)))
- X defn)
- X args (if (equal args "") "" " ")
- X keys
- X (if (equal prompts "") "" " ") prompts
- X (if (equal cmd "") "" " => ") cmd))
- X (message "%s%s%s runs %s%s"
- X (if inv "I " "") (if hyp "H " "") desc
- X msg
- X (if (equal notes "") ""
- X (format " (?=notes %s)" notes)))
- X (let ((key (read-char)))
- X (if (eq key ??)
- X (if (equal notes "")
- X (message "No notes for this command")
- X (while (string-match "," notes)
- X (aset notes (match-beginning 0) ? ))
- X (setq notes (sort (car (read-from-string
- X (format "(%s)" notes)))
- X '<))
- X (with-output-to-temp-buffer "*Help*"
- X (princ (format "%s\n\n" msg))
- X (set-buffer "*Calc Summary*")
- X (re-search-forward "^ *NOTES")
- X (while notes
- X (re-search-forward
- X (format "^ *%d\\. " (car notes)))
- X (beginning-of-line)
- X (let ((pt (point)))
- X (forward-line 1)
- X (or (re-search-forward "^ ? ?[0-9]+\\. " nil t)
- X (goto-char (point-max)))
- X (beginning-of-line)
- X (princ (buffer-substring pt (point))))
- X (setq notes (cdr notes)))
- X (print-help-return-message)))
- X (setq unread-command-char key))))
- X (if (or (null defn) (integerp defn))
- X (message "%s is undefined" desc)
- X (message "%s runs the command %s"
- X desc
- X (if (symbolp defn) defn (prin1-to-string defn))))))
- X (if inv (setq desc (concat "I " desc)))
- X (if hyp (setq desc (concat "H " desc)))
- X (calc-describe-thing desc "Key Index" nil
- X (> (length desc) (length key))))))
- )
- X
- (defun calc-describe-function (&optional func)
- X (interactive)
- X (or func
- X (setq func (intern (completing-read "Describe function: "
- X obarray nil t "calcFunc-"))))
- X (setq func (symbol-name func))
- X (if (string-match "\\`calc-." func)
- X (calc-describe-thing func "Command Index")
- X (calc-describe-thing (if (string-match "\\`calcFunc-." func)
- X (substring func 9)
- X func)
- X "Function Index"))
- )
- X
- (defun calc-describe-variable (&optional var)
- X (interactive)
- X (or var
- X (setq var (intern (completing-read "Describe variable: "
- X obarray nil t "var-"))))
- X (setq var (symbol-name var))
- X (calc-describe-thing var "Variable Index"
- X (if (string-match "\\`var-." var)
- X (substring var 4)
- X var))
- )
- X
- (defun calc-describe-thing (thing where &optional target not-quoted)
- X (message "Looking for `%s' in %s..." thing where)
- X (let ((savewin (current-window-configuration)))
- X (calc-info)
- X (Info-goto-node where)
- X (or (let ((case-fold-search nil))
- X (re-search-forward (format "\n\\* +%s: \\(.*\\)\\."
- X (regexp-quote thing))
- X nil t))
- X (and (string-match "\\`\\([a-z ]*\\)[0-9]\\'" thing)
- X (re-search-forward (format "\n\\* +%s[01]-9: \\(.*\\)\\."
- X (substring thing 0 -1))
- X nil t)
- X (setq thing (format "%s9" (substring thing 0 -1))))
- X (progn
- X (Info-last)
- X (set-window-configuration savewin)
- X (error "Can't find `%s' in %s" thing where)))
- X (let (Info-history)
- X (Info-goto-node (buffer-substring (match-beginning 1) (match-end 1))))
- X (or (let ((case-fold-search nil))
- X (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
- X (or target thing)
- X (or target thing)
- X (or target thing)) nil t)
- X (and not-quoted
- X (let ((case-fold-search t))
- X (search-forward (or target thing) nil t)))
- X (search-forward (format "`%s'" (or target thing)) nil t)
- X (search-forward (or target thing) nil t)))
- X (let ((case-fold-search t))
- X (or (search-forward (format "\\[`%s'\\]\\|(`%s')\\|\\<The[ \n]`%s'"
- X (or target thing)
- X (or target thing)
- X (or target thing)) nil t)
- X (search-forward (format "`%s'" (or target thing)) nil t)
- X (search-forward (or target thing) nil t))))
- X (beginning-of-line)
- X (message "Found `%s' in %s" thing where))
- )
- X
- (defun calc-view-news ()
- X (interactive)
- X (let ((path load-path))
- X (while (and path
- X (not (file-exists-p (expand-file-name "calc.el" (car path)))))
- X (setq path (cdr path)))
- X (or (and path
- X (file-exists-p (expand-file-name "README" (car path))))
- X (error "Can't locate Calc sources"))
- X (calc-quit)
- X (switch-to-buffer "*Help*")
- X (erase-buffer)
- X (insert-file-contents (expand-file-name "README" (car path)))
- X (search-forward "Summary of changes")
- X (forward-line -1)
- X (delete-region (point-min) (point))
- X (goto-char (point-min)))
- )
- X
- X
- X
- (defun calc-full-help ()
- X (interactive)
- X (with-output-to-temp-buffer "*Help*"
- X (princ (format "GNU Emacs Calculator version %s of %s.\n"
- X calc-version calc-version-date))
- X (princ " By Dave Gillespie, daveg@csvax.cs.caltech.edu")
- X (princ " / daveg@synaptics.com.\n")
- X (princ (format " Installed %s.\n" calc-installed-date))
- X (princ " Copyright (C) 1990, 1991 Free Software Foundation, Inc.\n\n")
- X (princ "Type `h s' for a more detailed summary.\n")
- X (princ "Or type `h i' to read the full Calc manual on-line.\n\n")
- X (princ "Basic keys:\n")
- X (let* ((calc-full-help-flag t))
- X (mapcar (function (lambda (x) (princ (format " %s\n" x))))
- X (nreverse (cdr (reverse (cdr (calc-help))))))
- X (mapcar (function (lambda (prefix)
- X (let ((msgs (funcall prefix)))
- X (if (car msgs)
- X (princ
- X (if (eq (nth 2 msgs) ?v)
- X "\n`v' or `V' prefix (vector/matrix) keys: \n"
- X (if (nth 2 msgs)
- X (format
- X "\n`%c' prefix (%s) keys:\n"
- X (nth 2 msgs)
- X (or (cdr (assq (nth 2 msgs)
- X calc-help-long-names))
- X (nth 1 msgs)))
- X (format "\n%s-modified keys:\n"
- X (capitalize (nth 1 msgs)))))))
- X (mapcar (function (lambda (x)
- X (princ (format " %s\n" x))))
- X (car msgs)))))
- X '(calc-inverse-prefix-help
- X calc-hyperbolic-prefix-help
- X calc-inv-hyp-prefix-help
- X calc-a-prefix-help
- X calc-b-prefix-help
- X calc-c-prefix-help
- X calc-d-prefix-help
- X calc-f-prefix-help
- X calc-g-prefix-help
- X calc-h-prefix-help
- X calc-j-prefix-help
- X calc-k-prefix-help
- X calc-m-prefix-help
- X calc-r-prefix-help
- X calc-s-prefix-help
- X calc-t-prefix-help
- X calc-u-prefix-help
- X calc-v-prefix-help
- X calc-shift-Y-prefix-help
- X calc-shift-Z-prefix-help
- X calc-z-prefix-help)))
- X (print-help-return-message))
- )
- X
- (defvar calc-help-long-names '( ( ?b . "binary/business" )
- X ( ?g . "graphics" )
- X ( ?j . "selection" )
- X ( ?k . "combinatorics/statistics" )
- X ( ?u . "units/statistics" )
- ))
- X
- (defun calc-h-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Help; Bindings; Info, Tutorial, Summary; News"
- X "describe: Key, C (briefly), Function, Variable")
- X "help" ?h)
- )
- X
- (defun calc-inverse-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("I + S (arcsin), C (arccos), T (arctan); Q (square)"
- X "I + E (ln), L (exp), B (alog: B^X); f E (lnp1), f L (expm1)"
- X "I + F (ceiling), R (truncate); a S (invert func)"
- X "I + a m (match-not); c h (from-hms); k n (prev prime)"
- X "I + f G (gamma-Q); f e (erfc); k B (etc., lower-tail dists)"
- X "I + V S (reverse sort); V G (reverse grade)"
- X "I + v s (remove subvec); v h (tail)"
- X "I + t + (alt sum), t M (mean with error)"
- X "I + t S (pop std dev), t C (pop covar)")
- X "inverse" nil)
- )
- X
- (defun calc-hyperbolic-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("H + S (sinh), C (cosh), T (tanh); E (exp10), L (log10)"
- X "H + F (float floor), R (float round); P (constant \"e\")"
- X "H + a d (total derivative); k c (permutations)"
- X "H + k b (bern-poly), k e (euler-poly); k s (stirling-2)"
- X "H + f G (gamma-g), f B (beta-B); v h (rhead), v k (rcons)"
- X "H + v e (expand w/filler); V H (weighted histogram)"
- X "H + a S (general solve eqn), j I (general isolate)"
- X "H + a R (widen/root), a N (widen/min), a X (widen/max)"
- X "H + t M (median), t S (variance), t C (correlation coef)"
- X "H + c f/F/c (pervasive float/frac/clean)")
- X "hyperbolic" nil)
- )
- X
- (defun calc-inv-hyp-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("I H + S (arcsinh), C (arccosh), T (arctanh)"
- X "I H + E (log10), L (exp10); f G (gamma-G)"
- X "I H + F (float ceiling), R (float truncate)"
- X "I H + t S (pop variance)"
- X "I H + a S (general invert func); v h (rtail)")
- X "inverse-hyperbolic" nil)
- )
- X
- X
- (defun calc-f-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("miN, maX; Hypot; Im, Re; Sign; [, ] (incr/decr)"
- X "Gamma, Beta, Erf, besselJ, besselY"
- X "SHIFT + int-sQrt; Int-log, Exp(x)-1, Ln(x+1); arcTan2"
- X "SHIFT + Abssqr; Mantissa, eXponent, Scale"
- X "SHIFT + incomplete: Gamma-P, Beta-I")
- X "functions" ?f)
- )
- X
- X
- (defun calc-s-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Store, inTo, Xchg, Unstore; Recall, 0-9; : (:=); = (=>)"
- X "Let; Copy; Declare; Insert, Perm; Edit"
- X "Negate, +, -, *, /, ^, &, |, [, ]; Map"
- X "SHIFT + Decls, GenCount, TimeZone"
- X "SHIFT + LineStyles, PointStyles, plotRejects"
- X "SHIFT + Eval-, AlgSimp-, ExtSimp-, UnitSimp-, FitRules")
- X "store" ?s)
- )
- X
- (defun calc-r-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("digits 0-9: recall, same as `s r 0-9'")
- X "recall" ?r)
- )
- X
- X
- (defun calc-j-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Select, Additional, Once; eVal, Formula; Rewrite"
- X "More, Less, 1-9, Next, Previous"
- X "Unselect, Clear; Display; Enable; Breakable"
- X "' (replace), ` (edit), +, -, *, /, RET (grab), DEL"
- X "SHIFT + swap: Left, Right; maybe: Select, Once"
- X "SHIFT + Commute, Merge, Distrib, jump-Eqn, Isolate"
- X "SHIFT + Negate, & (invert); Unpack")
- X "select" ?j)
- )
- X
- X
- (defun calc-a-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Simplify, Extended-simplify, eVal; \" (exp-formula)"
- X "eXpand, Collect, Factor, Apart, Norm-rat"
- X "GCD, /, \\, % (polys); Polint"
- X "Derivative, Integral, Taylor; _ (subscr)"
- X "suBstitute; Rewrite, Match"
- X "SHIFT + Solve; Root, miN, maX; Poly-roots; Fit"
- X "SHIFT + Map; Tabulate, + (sum), * (prod); num-Integ"
- X "relations: =, # (not =), <, >, [ (< or =), ] (> or =)"
- X "logical: & (and), | (or), ! (not); : (if)"
- X "misc: { (in-set); . (rmeq)")
- X "algebra" ?a)
- )
- X
- X
- (defun calc-b-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("And, Or, Xor, Diff, Not; Wordsize, Clip"
- X "Lshift, Rshift, roTate; SHIFT + signed Lshift, Rshift"
- X "SHIFT + business: Pv, Npv, Fv, pMt, #pmts, raTe, Irr"
- X "SHIFT + business: Sln, sYd, Ddb")
- X "binary/bus" ?b)
- )
- X
- X
- (defun calc-c-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Deg, Rad, HMS; Float; Polar/rect; Clean, 0-9"
- X "SHIFT + Fraction")
- X "convert" ?c)
- )
- X
- X
- (defun calc-d-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Group, \",\"; Normal, Fix, Sci, Eng, \".\"; Over"
- X "Radix, Zeros, 2, 8, 0, 6; Hms; Date; Complex, I, J"
- X "Why; Line-nums, line-Breaks; <, =, > (justify); Plain"
- X "\" (strings); Truncate, [, ]; ` (align); SPC (refresh)"
- X "SHIFT + language: Normal, One-line, Big, Unformatted"
- X "SHIFT + language: C, Pascal, Fortran; TeX, Eqn"
- X "SHIFT + language: Mathematica, W=Maple")
- X "display" ?d)
- )
- X
- X
- (defun calc-g-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Fast; Add, Delete, Juggle; Plot, Clear; Quit"
- X "Header, Name, Grid, Border, Key; View-commands, X-display"
- X "x-axis: Range, Title, Log, Zero; lineStyle"
- X "SHIFT + y-axis: Range, Title, Log, Zero; pointStyle"
- X "SHIFT + Print; Device, Output-file; X-geometry"
- X "SHIFT + Num-pts; Command, Kill, View-trail"
- X "SHIFT + 3d: Fast, Add; CTRL + z-axis: Range, Title, Log")
- X "graph" ?g)
- )
- X
- X
- (defun calc-k-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("GCD, LCM; Choose (binomial), Double-factorial"
- X "Random, random-Again, sHuffle"
- X "Factors, Prime-test, Next-prime, Totient, Moebius"
- X "Bernoulli, Euler, Stirling"
- X "SHIFT + Extended-gcd"
- X "SHIFT + dists: Binomial, Chi-square, F, Normal"
- X "SHIFT + dists: Poisson, student's-T")
- X "combinatorics" ?k)
- )
- X
- X
- (defun calc-m-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Deg, Rad, HMS; Frac; Polar; Inf; Alg, Total; Symb; Vec/mat"
- X "Working; Xtensions; Mode-save"
- X "SHIFT + Shifted-prefixes, mode-Filename; Record; reCompute"
- X "SHIFT + simplify: Off, Num, Default, Bin, Alg, Ext, Units")
- X "mode" ?m)
- )
- X
- X
- (defun calc-t-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Display; Fwd, Back; Next, Prev, Here, [, ]; Yank"
- X "Search, Rev; In, Out; <, >; Kill; Marker; . (abbrev)"
- X "SHIFT + time: Now; Part; Date, Julian, Unix, Czone"
- X "SHIFT + time: newWeek, newMonth, newYear; Incmonth"
- X "digits 0-9: store-to, same as `s t 0-9'")
- X "trail/time" ?t)
- )
- X
- X
- (defun calc-u-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Simplify, Convert, Temperature-convert, Base-units"
- X "Autorange; Remove, eXtract; Explain; View-table"
- X "Define, Undefine, Get-defn, Permanent"
- X "SHIFT + View-table-other-window"
- X "SHIFT + stat: Mean, G-mean, Std-dev, Covar, maX, miN"
- X "SHIFT + stat: + (sum), - (asum), * (prod), # (count)")
- X "units/stat" ?u)
- )
- X
- X
- (defun calc-v-prefix-help ()
- X (interactive)
- X (calc-do-prefix-help
- X '("Pack, Unpack, Identity, Diagonal, indeX, Build"
- X "Row, Column, Subvector; Length; Find; Mask, Expand"
- X "Tranpose, Arrange, reVerse; Head, Kons; rNorm"
- X "SHIFT + Det, & (inverse), LUD, Trace, conJtrn, Cross"
- X "SHIFT + Sort, Grade, Histogram; cNorm"
- X "SHIFT + Apply, Map, Reduce, accUm, Inner-, Outer-prod"
- X "SHIFT + sets: V (union), ^ (intersection), - (diff)"
- X "SHIFT + sets: Xor, ~ (complement), Floor, Enum"
- X "SHIFT + sets: : (span), # (card), + (rdup)"
- X "<, =, > (justification); , (commas); [, {, ( (brackets)"
- X "} (matrix brackets); . (abbreviate); / (multi-lines)")
- X "vec/mat" ?v)
- )
- X
- SHAR_EOF
- chmod 0644 calc-help.el ||
- echo 'restore of calc-help.el failed'
- Wc_c="`wc -c < 'calc-help.el'`"
- test 22452 -eq "$Wc_c" ||
- echo 'calc-help.el: original size 22452, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= calc-incom.el ==============
- if test -f 'calc-incom.el' -a X"$1" != X"-c"; then
- echo 'x - skipping calc-incom.el (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting calc-incom.el (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'calc-incom.el' &&
- ;; Calculator for GNU Emacs, part II [calc-incom.el]
- ;; Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- ;; Written by Dave Gillespie, daveg@csvax.cs.caltech.edu.
- X
- ;; This file is part of GNU Emacs.
- X
- ;; GNU Emacs is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY. No author or distributor
- ;; accepts responsibility to anyone for the consequences of using it
- ;; or for whether it serves any particular purpose or works at all,
- ;; unless he says so in writing. Refer to the GNU Emacs General Public
- ;; License for full details.
- X
- ;; Everyone is granted permission to copy, modify and redistribute
- ;; GNU Emacs, but only under the conditions described in the
- ;; GNU Emacs General Public License. A copy of this license is
- ;; supposed to have been given to you along with GNU Emacs so you
- ;; can know your rights and responsibilities. It should be in a
- ;; file named COPYING. Among other things, the copyright notice
- ;; and this notice must be preserved on all copies.
- X
- X
- X
- ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
- X
- (require 'calc-macs)
- X
- (defun calc-Need-calc-incom () nil)
- X
- X
- ;;; Incomplete forms.
- X
- (defun calc-begin-complex ()
- X (interactive)
- X (calc-wrapper
- X (if (or calc-algebraic-mode calc-incomplete-algebraic-mode)
- X (calc-alg-entry "(")
- X (calc-push (list 'incomplete calc-complex-mode))))
- )
- X
- (defun calc-end-complex ()
- X (interactive)
- X (calc-comma t)
- X (calc-wrapper
- X (let ((top (calc-top 1)))
- X (if (and (eq (car-safe top) 'incomplete)
- X (eq (nth 1 top) 'intv))
- X (progn
- X (if (< (length top) 4)
- X (setq top (append top '((neg (var inf var-inf))))))
- X (if (< (length top) 5)
- X (setq top (append top '((var inf var-inf)))))
- X (calc-enter-result 1 "..)" (cdr top)))
- X (if (not (and (eq (car-safe top) 'incomplete)
- X (memq (nth 1 top) '(cplx polar))))
- X (error "Not entering a complex number"))
- X (while (< (length top) 4)
- X (setq top (append top '(0))))
- X (if (not (and (math-realp (nth 2 top))
- X (math-anglep (nth 3 top))))
- X (error "Components must be real"))
- X (calc-enter-result 1 "()" (cdr top)))))
- )
- X
- (defun calc-begin-vector ()
- X (interactive)
- X (calc-wrapper
- X (if (or calc-algebraic-mode calc-incomplete-algebraic-mode)
- X (calc-alg-entry "[")
- X (calc-push '(incomplete vec))))
- )
- X
- (defun calc-end-vector ()
- X (interactive)
- X (calc-comma t)
- X (calc-wrapper
- X (let ((top (calc-top 1)))
- X (if (and (eq (car-safe top) 'incomplete)
- X (eq (nth 1 top) 'intv))
- X (progn
- X (if (< (length top) 4)
- X (setq top (append top '((neg (var inf var-inf))))))
- X (if (< (length top) 5)
- X (setq top (append top '((var inf var-inf)))))
- X (setcar (cdr (cdr top)) (1+ (nth 2 top)))
- X (calc-enter-result 1 "..]" (cdr top)))
- X (if (not (and (eq (car-safe top) 'incomplete)
- X (eq (nth 1 top) 'vec)))
- X (error "Not entering a vector"))
- X (calc-pop-push-record 1 "[]" (cdr top)))))
- )
- X
- (defun calc-comma (&optional allow-polar)
- X (interactive)
- X (calc-wrapper
- X (let ((num (calc-find-first-incomplete
- X (nthcdr calc-stack-top calc-stack) 1)))
- X (if (= num 0)
- X (error "Not entering a vector or complex number"))
- X (let* ((inc (calc-top num))
- X (stuff (calc-top-list (1- num)))
- X (new (append inc stuff)))
- X (if (and (null stuff)
- X (not allow-polar)
- X (or (eq (nth 1 inc) 'vec)
- X (< (length new) 4)))
- X (setq new (append new
- X (if (= (length new) 2)
- X '(0)
- X (nthcdr (1- (length new)) new)))))
- X (or allow-polar
- X (if (eq (nth 1 new) 'polar)
- X (setq new (append '(incomplete cplx) (cdr (cdr new))))
- X (if (eq (nth 1 new) 'intv)
- X (setq new (append '(incomplete cplx)
- X (cdr (cdr (cdr new))))))))
- X (if (and (memq (nth 1 new) '(cplx polar))
- X (> (length new) 4))
- X (error "Too many components in complex number"))
- X (if (and (eq (nth 1 new) 'intv)
- X (> (length new) 5))
- X (error "Too many components in interval form"))
- X (calc-pop-push num new))))
- )
- X
- (defun calc-semi ()
- X (interactive)
- X (calc-wrapper
- X (let ((num (calc-find-first-incomplete
- X (nthcdr calc-stack-top calc-stack) 1)))
- X (if (= num 0)
- X (error "Not entering a vector or complex number"))
- X (let ((inc (calc-top num))
- X (stuff (calc-top-list (1- num))))
- X (if (eq (nth 1 inc) 'cplx)
- X (setq inc (append '(incomplete polar) (cdr (cdr inc))))
- X (if (eq (nth 1 inc) 'intv)
- X (setq inc (append '(incomplete polar) (cdr (cdr (cdr inc)))))))
- X (cond ((eq (nth 1 inc) 'polar)
- X (let ((new (append inc stuff)))
- X (if (> (length new) 4)
- X (error "Too many components in complex number")
- X (if (= (length new) 2)
- X (setq new (append new '(1)))))
- X (calc-pop-push num new)))
- X ((null stuff)
- X (if (> (length inc) 2)
- X (if (math-vectorp (nth 2 inc))
- X (calc-comma)
- X (calc-pop-push 1
- X (list 'incomplete 'vec (cdr (cdr inc)))
- X (list 'incomplete 'vec)))))
- X ((math-vectorp (car stuff))
- X (calc-comma))
- X ((eq (car-safe (car-safe (nth (+ num calc-stack-top)
- X calc-stack))) 'incomplete)
- X (calc-end-vector)
- X (calc-comma)
- X (let ((calc-algebraic-mode nil)
- X (calc-incomplete-algebraic-mode nil))
- X (calc-begin-vector)))
- X ((or (= (length inc) 2)
- X (math-vectorp (nth 2 inc)))
- X (calc-pop-push num
- X (append inc (list (cons 'vec stuff)))
- X (list 'incomplete 'vec)))
- X (t
- X (calc-pop-push num
- X (list 'incomplete 'vec
- X (cons 'vec (append (cdr (cdr inc)) stuff)))
- X (list 'incomplete 'vec)))))))
- )
- X
- (defun calc-digit-dots ()
- X (if (eq calc-prev-char ?.)
- X (progn
- X (delete-backward-char 1)
- X (if (calc-minibuffer-contains ".*\\.\\'")
- X (delete-backward-char 1))
- X (setq calc-prev-char 'dots
- X last-command-char 32)
- X (if calc-prev-prev-char
- X (calcDigit-nondigit)
- X (setq calc-digit-value nil)
- X (erase-buffer)
- X (exit-minibuffer)))
- X ;; just ignore extra decimal point, anticipating ".."
- X (delete-backward-char 1))
- )
- X
- (defun calc-dots ()
- X (interactive)
- X (calc-wrapper
- X (let ((num (calc-find-first-incomplete
- X (nthcdr calc-stack-top calc-stack) 1)))
- X (if (= num 0)
- X (error "Not entering an interval form"))
- X (let* ((inc (calc-top num))
- X (stuff (calc-top-list (1- num)))
- X (new (append inc stuff)))
- X (if (not (eq (nth 1 new) 'intv))
- X (setq new (append '(incomplete intv)
- X (if (eq (nth 1 new) 'vec) '(2) '(0))
- X (cdr (cdr new)))))
- X (if (and (null stuff)
- X (= (length new) 3))
- X (setq new (append new '((neg (var inf var-inf))))))
- X (if (> (length new) 5)
- X (error "Too many components in interval form"))
- X (calc-pop-push num new))))
- )
- X
- (defun calc-find-first-incomplete (stack n)
- X (cond ((null stack)
- X 0)
- X ((eq (car-safe (car-safe (car stack))) 'incomplete)
- X n)
- X (t
- X (calc-find-first-incomplete (cdr stack) (1+ n))))
- )
- X
- (defun calc-incomplete-error (a)
- X (cond ((memq (nth 1 a) '(cplx polar))
- X (error "Complex number is incomplete"))
- X ((eq (nth 1 a) 'vec)
- X (error "Vector is incomplete"))
- X ((eq (nth 1 a) 'intv)
- X (error "Interval form is incomplete"))
- X (t (error "Object is incomplete")))
- )
- X
- X
- X
- SHAR_EOF
- chmod 0644 calc-incom.el ||
- echo 'restore of calc-incom.el failed'
- Wc_c="`wc -c < 'calc-incom.el'`"
- test 7165 -eq "$Wc_c" ||
- echo 'calc-incom.el: original size 7165, current size' "$Wc_c"
- rm -f _shar_wnt_.tmp
- fi
- # ============= calc-keypd.el ==============
- if test -f 'calc-keypd.el' -a X"$1" != X"-c"; then
- echo 'x - skipping calc-keypd.el (File already exists)'
- rm -f _shar_wnt_.tmp
- else
- > _shar_wnt_.tmp
- echo 'x - extracting calc-keypd.el (Text)'
- sed 's/^X//' << 'SHAR_EOF' > 'calc-keypd.el' &&
- ;; Calculator for GNU Emacs, part II [calc-keypd.el]
- ;; Copyright (C) 1990, 1991 Free Software Foundation, Inc.
- ;; Written by Dave Gillespie, daveg@csvax.cs.caltech.edu.
- X
- ;; This file is part of GNU Emacs.
- X
- ;; GNU Emacs is distributed in the hope that it will be useful,
- ;; but WITHOUT ANY WARRANTY. No author or distributor
- ;; accepts responsibility to anyone for the consequences of using it
- ;; or for whether it serves any particular purpose or works at all,
- ;; unless he says so in writing. Refer to the GNU Emacs General Public
- ;; License for full details.
- X
- ;; Everyone is granted permission to copy, modify and redistribute
- ;; GNU Emacs, but only under the conditions described in the
- ;; GNU Emacs General Public License. A copy of this license is
- ;; supposed to have been given to you along with GNU Emacs so you
- ;; can know your rights and responsibilities. It should be in a
- ;; file named COPYING. Among other things, the copyright notice
- ;; and this notice must be preserved on all copies.
- X
- X
- X
- ;; This file is autoloaded from calc-ext.el.
- (require 'calc-ext)
- X
- (require 'calc-macs)
- X
- (defun calc-Need-calc-keypd () nil)
- X
- X
- X
- ;;; Pictorial interface to Calc using the X window system mouse.
- X
- (defvar calc-keypad-buffer nil)
- (defvar calc-keypad-menu 0)
- (defvar calc-keypad-full-layout nil)
- (defvar calc-keypad-input nil)
- (defvar calc-keypad-prev-input nil)
- (defvar calc-keypad-prev-x-left-click nil)
- (defvar calc-keypad-prev-x-middle-click nil)
- (defvar calc-keypad-prev-x-right-click nil)
- (defvar calc-keypad-said-hello nil)
- X
- (defvar calc-keypad-map nil)
- (if calc-keypad-map
- X ()
- X (setq calc-keypad-map (make-sparse-keymap))
- X (define-key calc-keypad-map " " 'calc-keypad-press)
- X (define-key calc-keypad-map "\r" 'calc-keypad-press)
- X (define-key calc-keypad-map "\t" 'calc-keypad-menu)
- X (define-key calc-keypad-map "q" 'calc-keypad-off))
- X
- (defun calc-do-keypad (&optional full-display interactive)
- X (calc-create-buffer)
- X (let ((calcbuf (current-buffer)))
- X (or (and calc-keypad-buffer
- X (buffer-name calc-keypad-buffer))
- X (progn
- X (setq calc-keypad-buffer (get-buffer-create "*Calc Keypad*"))
- X (set-buffer calc-keypad-buffer)
- X (use-local-map calc-keypad-map)
- X (setq major-mode 'calc-keypad)
- X (setq mode-name "Calculator")
- X (put 'calc-keypad 'mode-class 'special)
- X (make-local-variable 'calc-main-buffer)
- X (setq calc-main-buffer calcbuf)
- X (calc-keypad-redraw)))
- X (let ((width 29)
- X (height 17)
- X win old-win)
- X (if (setq win (get-buffer-window "*Calculator*"))
- X (delete-window win))
- X (if (setq win (get-buffer-window "*Calc Trail*"))
- X (if (one-window-p)
- X (switch-to-buffer (other-buffer))
- X (delete-window win)))
- X (if (setq win (get-buffer-window calc-keypad-buffer))
- X (progn
- X (bury-buffer "*Calculator*")
- X (bury-buffer "*Calc Trail*")
- X (bury-buffer calc-keypad-buffer)
- X (if (one-window-p)
- X (switch-to-buffer (other-buffer))
- X (delete-window win))
- X (if (and calc-keypad-prev-x-left-click
- X (eq (aref mouse-map 0) 'calc-keypad-x-right-click)
- X (eq (aref mouse-map 1) 'calc-keypad-x-middle-click)
- X (eq (aref mouse-map 2) 'calc-keypad-x-left-click))
- X (progn
- X (aset mouse-map 0 calc-keypad-prev-x-right-click)
- X (aset mouse-map 1 calc-keypad-prev-x-middle-click)
- X (aset mouse-map 2 calc-keypad-prev-x-left-click)
- X (setq calc-keypad-prev-x-left-click nil))))
- X (setq calc-was-keypad-mode t
- X old-win (get-largest-window))
- X (if (or (< (window-height old-win) (+ height 6))
- X (< (window-width old-win) (+ width 15))
- X full-display)
- X (delete-other-windows old-win))
- X (if (< (window-height old-win) (+ height 4))
- X (error "Screen is not tall enough for this mode"))
- X (if full-display
- X (progn
- X (setq win (split-window old-win (- (window-height old-win)
- X height 1)))
- X (set-window-buffer old-win (calc-trail-buffer))
- X (set-window-buffer win calc-keypad-buffer)
- X (set-window-start win 1)
- X (setq win (split-window win (+ width 3) t))
- X (set-window-buffer win calcbuf))
- X (if (or t ; left-side keypad not yet fully implemented
- X (< (save-excursion
- X (set-buffer (window-buffer old-win))
- X (current-column))
- X (/ (window-width) 2)))
- X (setq win (split-window old-win (- (window-width old-win)
- X width 2)
- X t))
- X (setq old-win (split-window old-win (+ width 2) t)))
- X (set-window-buffer win calc-keypad-buffer)
- X (set-window-start win 1)
- X (split-window win (- (window-height win) height 1))
- X (set-window-buffer win calcbuf))
- X (select-window old-win)
- X (if (and (eq window-system 'x)
- X (not calc-keypad-prev-x-left-click))
- X (progn
- X (setq calc-keypad-prev-x-right-click (aref mouse-map 0)
- X calc-keypad-prev-x-middle-click (aref mouse-map 1)
- X calc-keypad-prev-x-left-click (aref mouse-map 2))
- X (aset mouse-map 0 'calc-keypad-x-right-click)
- X (aset mouse-map 1 'calc-keypad-x-middle-click)
- X (aset mouse-map 2 'calc-keypad-x-left-click)))
- X (message "Welcome to GNU Emacs Calc! Use the left and right mouse buttons.")
- X (run-hooks 'calc-keypad-start-hook)
- X (and calc-keypad-said-hello interactive
- X (progn
- X (sit-for 2)
- X (message "")))
- X (setq calc-keypad-said-hello t))))
- X (setq calc-keypad-input nil)
- )
- X
- (defun calc-keypad-off ()
- X (interactive)
- X (if calc-standalone-flag
- X (save-buffers-kill-emacs nil)
- X (calc-keypad))
- )
- X
- (defun calc-keypad-redraw ()
- X (set-buffer calc-keypad-buffer)
- X (setq buffer-read-only t)
- X (setq calc-keypad-full-layout (append (symbol-value (nth calc-keypad-menu
- X calc-keypad-menus))
- X calc-keypad-layout))
- X (let ((buffer-read-only nil)
- X (row calc-keypad-full-layout)
- X (y 0))
- X (erase-buffer)
- X (insert "\n")
- X (while row
- X (let ((col (car row)))
- X (while col
- X (let* ((key (car col))
- X (cwid (if (>= y 4)
- X 5
- X (if (and (= y 3) (eq col (car row)))
- X (progn (setq col (cdr col)) 9)
- X 4)))
- X (name (if (and calc-standalone-flag
- X (eq (nth 1 key) 'calc-keypad-off))
- X "EXIT"
- X (if (> (length (car key)) cwid)
- X (substring (car key) 0 cwid)
- X (car key))))
- X (wid (length name))
- X (pad (- cwid (/ wid 2))))
- X (insert (make-string (/ (- cwid wid) 2) 32)
- X name
- X (make-string (/ (- cwid wid -1) 2) 32)
- X (if (equal name "MENU")
- X (int-to-string (1+ calc-keypad-menu))
- X "|")))
- X (or (setq col (cdr col))
- X (insert "\n")))
- X (insert (if (>= y 4)
- X "-----+-----+-----+-----+-----"
- X (if (= y 3)
- X "-----+---+-+--+--+-+---++----"
- X "----+----+----+----+----+----"))
- X (if (= y 7) "+\n" "|\n"))
- X (setq y (1+ y)
- X row (cdr row)))))
- X (setq calc-keypad-prev-input t)
- X (calc-keypad-show-input)
- X (goto-char (point-min))
- )
- X
- (defun calc-keypad-show-input ()
- X (or (equal calc-keypad-input calc-keypad-prev-input)
- X (let ((buffer-read-only nil))
- X (save-excursion
- X (goto-char (point-min))
- X (forward-line 1)
- X (delete-region (point-min) (point))
- X (if calc-keypad-input
- X (insert "Calc: " calc-keypad-input "\n")
- X (insert "----+-----Calc " calc-version "-----+----"
- X (int-to-string (1+ calc-keypad-menu))
- X "\n")))))
- X (setq calc-keypad-prev-input calc-keypad-input)
- )
- X
- (defun calc-keypad-press ()
- X (interactive)
- X (or (eq major-mode 'calc-keypad)
- X (error "Must be in *Calc Keypad* buffer for this command"))
- X (let* ((row (save-excursion
- X (beginning-of-line)
- X (count-lines (point-min) (point))))
- X (y (/ row 2))
- X (x (/ (current-column) (if (>= y 4) 6 5)))
- X radix frac inv
- X (hyp (save-excursion
- X (set-buffer calc-main-buffer)
- X (setq radix calc-number-radix
- X frac calc-prefer-frac
- X inv calc-inverse-flag)
- X calc-hyperbolic-flag))
- X (invhyp t)
- X (menu (symbol-value (nth calc-keypad-menu calc-keypad-menus)))
- X (input calc-keypad-input)
- X (iexpon (and input
- X (or (string-match "\\*[0-9]+\\.\\^" input)
- X (and (<= radix 14) (string-match "e" input)))
- X (match-end 0)))
- X (key (nth x (nth y calc-keypad-full-layout)))
- X (cmd (or (nth (if inv (if hyp 4 2) (if hyp 3 99)) key)
- X (setq invhyp nil)
- X (nth 1 key)))
- X (isstring (and (consp cmd) (stringp (car cmd))))
- X (calc-is-keypad-press t))
- X (if invhyp (calc-wrapper)) ; clear Inv and Hyp flags
- X (unwind-protect
- X (cond ((or (null cmd)
- X (= (% row 2) 0))
- X (beep))
- X ((and (> (minibuffer-depth) 0))
- X (cond (isstring
- X (setq unread-command-char (aref (car cmd) 0)))
- X ((eq cmd 'calc-pop)
- X (setq unread-command-char ?\177))
- X ((eq cmd 'calc-enter)
- X (setq unread-command-char 13))
- X ((eq cmd 'calc-undo)
- X (setq unread-command-char 7))
- X (t
- X (beep))))
- X ((and input (string-match "STO\\|RCL" input))
- X (cond ((and isstring (string-match "[0-9]" (car cmd)))
- X (setq calc-keypad-input nil)
- X (let ((var (intern (concat "var-q" (car cmd)))))
- X (cond ((equal input "STO+") (calc-store-plus var))
- X ((equal input "STO-") (calc-store-minus var))
- X ((equal input "STO*") (calc-store-times var))
- X ((equal input "STO/") (calc-store-div var))
- X ((equal input "STO^") (calc-store-power var))
- X ((equal input "STOn") (calc-store-neg 1 var))
- X ((equal input "STO&") (calc-store-inv 1 var))
- X ((equal input "STO") (calc-store-into var))
- X (t (calc-recall var)))))
- X ((memq cmd '(calc-pop calc-undo))
- X (setq calc-keypad-input nil))
- X ((and (equal input "STO")
- X (setq frac (assq cmd '( ( calc-plus . "+" )
- X ( calc-minus . "-" )
- X ( calc-times . "*" )
- X ( calc-divide . "/" )
- X ( calc-power . "^")
- X ( calc-change-sign . "n")
- X ( calc-inv . "&") ))))
- X (setq calc-keypad-input (concat input (cdr frac))))
- X (t
- X (beep))))
- X (isstring
- X (setq cmd (car cmd))
- X (if (or (and (equal cmd ".")
- X input
- X (string-match "[.:e^]" input))
- X (and (equal cmd "e")
- X input
- X (or (and (<= radix 14) (string-match "e" input))
- X (string-match "\\^\\|[-.:]\\'" input)))
- X (and (not (equal cmd "."))
- X (let ((case-fold-search nil))
- X (string-match cmd "0123456789ABCDEF"
- X (if (string-match
- X "[e^]" (or input ""))
- X 10 radix)))))
- X (beep)
- X (setq calc-keypad-input (concat
- X (and (/= radix 10)
- X (or (not input)
- X (equal input "-"))
- X (format "%d#" radix))
- X (and (or (not input)
- X (equal input "-"))
- X (or (and (equal cmd "e") "1")
- X (and (equal cmd ".")
- X (if frac "1" "0"))))
- X input
- X (if (and (equal cmd ".") frac)
- X ":"
- X (if (and (equal cmd "e")
- X (or (not input)
- X (string-match
- X "#" input))
- X (> radix 14))
- X (format "*%d.^" radix)
- X cmd))))))
- X ((and (eq cmd 'calc-change-sign)
- X input)
- X (let* ((epos (or iexpon 0))
- X (suffix (substring input epos)))
- X (setq calc-keypad-input (concat
- X (substring input 0 epos)
- X (if (string-match "\\`-" suffix)
- X (substring suffix 1)
- X (concat "-" suffix))))))
- X ((and (eq cmd 'calc-pop)
- X input)
- X (if (equal input "")
- X (beep)
- X (setq calc-keypad-input (substring input 0
- X (or (string-match
- X "\\*[0-9]+\\.\\^\\'"
- X input)
- X -1)))))
- X ((and (eq cmd 'calc-undo)
- X input)
- X (setq calc-keypad-input nil))
- X (t
- X (if input
- X (let ((val (math-read-number input)))
- X (setq calc-keypad-input nil)
- X (if val
- X (calc-wrapper
- X (calc-push-list (list (calc-record
- X (calc-normalize val)))))
- X (or (equal input "")
- X (beep))
- X (setq cmd nil))
- X (if (eq cmd 'calc-enter) (setq cmd nil))))
- X (setq prefix-arg current-prefix-arg)
- X (if cmd
- X (if (and (consp cmd) (eq (car cmd) 'progn))
- X (while (setq cmd (cdr cmd))
- X (if (integerp (car cmd))
- X (setq prefix-arg (car cmd))
- X (command-execute (car cmd))))
- X (command-execute cmd)))))
- X (set-buffer calc-keypad-buffer)
- X (calc-keypad-show-input)))
- )
- X
- (defun calc-keypad-x-left-click (arg)
- X "Handle a left-button mouse click in Calc Keypad window."
- X (let (coords)
- X (if (and calc-keypad-buffer
- X (buffer-name calc-keypad-buffer)
- X (get-buffer-window calc-keypad-buffer)
- X (setq coords (coordinates-in-window-p
- X arg (get-buffer-window calc-keypad-buffer))))
- X (let ((win (selected-window)))
- X (unwind-protect
- X (progn
- X (x-mouse-set-point arg)
- X (calc-keypad-press))
- X (and (window-point win)
- X (select-window win))))
- X (funcall calc-keypad-prev-x-left-click arg)))
- )
- X
- (defun calc-keypad-x-right-click (arg)
- X "Handle a right-button mouse click in Calc Keypad window."
- X (if (and calc-keypad-buffer
- X (buffer-name calc-keypad-buffer)
- X (get-buffer-window calc-keypad-buffer)
- X (coordinates-in-window-p
- X arg (get-buffer-window calc-keypad-buffer)))
- X (save-excursion
- X (set-buffer calc-keypad-buffer)
- X (calc-keypad-menu))
- X (funcall calc-keypad-prev-x-right-click arg))
- )
- X
- (defun calc-keypad-x-middle-click (arg)
- X "Handle a middle-button mouse click in Calc Keypad window."
- X (if (and calc-keypad-buffer
- X (buffer-name calc-keypad-buffer)
- X (get-buffer-window calc-keypad-buffer)
- X (coordinates-in-window-p
- X arg (get-buffer-window calc-keypad-buffer)))
- X (save-excursion
- X (set-buffer calc-keypad-buffer)
- X (calc-keypad-menu-back))
- X (funcall calc-keypad-prev-x-middle-click arg))
- )
- X
- (defun calc-keypad-menu ()
- X (interactive)
- X (or (eq major-mode 'calc-keypad)
- X (error "Must be in *Calc Keypad* buffer for this command"))
- X (while (progn (setq calc-keypad-menu (% (1+ calc-keypad-menu)
- X (length calc-keypad-menus)))
- X (not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
- X (calc-keypad-redraw)
- )
- X
- (defun calc-keypad-menu-back ()
- X (interactive)
- X (or (eq major-mode 'calc-keypad)
- X (error "Must be in *Calc Keypad* buffer for this command"))
- X (while (progn (setq calc-keypad-menu (% (1- (+ calc-keypad-menu
- X (length calc-keypad-menus)))
- X (length calc-keypad-menus)))
- X (not (symbol-value (nth calc-keypad-menu calc-keypad-menus)))))
- X (calc-keypad-redraw)
- )
- X
- (defun calc-keypad-store ()
- X (interactive)
- X (setq calc-keypad-input "STO")
- )
- X
- (defun calc-keypad-recall ()
- X (interactive)
- X (setq calc-keypad-input "RCL")
- )
- X
- (defun calc-pack-interval (mode)
- X (interactive "p")
- X (if (or (< mode 0) (> mode 3))
- X (error "Open/close code should be in the range from 0 to 3."))
- X (calc-pack (- -6 mode))
- )
- X
- (defun calc-keypad-execute ()
- X (interactive)
- X (let* ((prompt "Calc keystrokes: ")
- X (flush 'x-flush-mouse-queue)
- X (prefix nil)
- X keys cmd)
- X (save-excursion
- X (calc-select-buffer)
- X (while (progn
- X (setq keys (read-key-sequence prompt))
- X (setq cmd (key-binding keys))
- X (if (or (memq cmd '(calc-inverse
- X calc-hyperbolic
- X universal-argument
- X digit-argument
- X negative-argument))
- X (and prefix (string-match "\\`\e?[-0-9]\\'" keys)))
- X (progn
- X (setq last-command-char (aref keys (1- (length keys))))
- X (command-execute cmd)
- X (setq flush 'not-any-more
- X prefix t
- X prompt (concat prompt (key-description keys) " ")))
- X (eq cmd flush))))) ; skip mouse-up event
- X (message "")
- X (if (commandp cmd)
- X (command-execute cmd)
- X (error "Not a Calc command: %s" (key-description keys))))
- )
- X
- X
- ;;; |----+----+----+----+----+----|
- ;;; | ENTER |+/- |EEX |UNDO| <- |
- ;;; |-----+---+-+--+--+-+---++----|
- ;;; | INV | 7 | 8 | 9 | / |
- ;;; |-----+-----+-----+-----+-----|
- ;;; | HYP | 4 | 5 | 6 | * |
- ;;; |-----+-----+-----+-----+-----|
- ;;; |EXEC | 1 | 2 | 3 | - |
- ;;; |-----+-----+-----+-----+-----|
- ;;; | OFF | 0 | . | PI | + |
- ;;; |-----+-----+-----+-----+-----|
- X
- (defvar calc-keypad-layout
- X '( ( ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
- X ( "ENTER" calc-enter calc-roll-down calc-roll-up calc-over )
- X ( "+/-" calc-change-sign calc-inv (progn -4 calc-pack) )
- X ( "EEX" ("e") (progn calc-num-prefix calc-pack-interval)
- X (progn -5 calc-pack) )
- X ( "UNDO" calc-undo calc-redo calc-last-args )
- X ( "<-" calc-pop (progn 0 calc-pop)
- X (progn calc-num-prefix calc-pop) ) )
- X ( ( "INV" calc-inverse )
- X ( "7" ("7") calc-round )
- X ( "8" ("8") (progn 2 calc-clean-num) )
- X ( "9" ("9") calc-float )
- X ( "/" calc-divide (progn calc-inverse calc-power) ) )
- X ( ( "HYP" calc-hyperbolic )
- X ( "4" ("4") calc-ln calc-log10 )
- X ( "5" ("5") calc-exp calc-exp10 )
- X ( "6" ("6") calc-abs )
- X ( "*" calc-times calc-power ) )
- X ( ( "EXEC" calc-keypad-execute )
- X ( "1" ("1") calc-arcsin calc-sin )
- X ( "2" ("2") calc-arccos calc-cos )
- X ( "3" ("3") calc-arctan calc-tan )
- X ( "-" calc-minus calc-conj ) )
- X ( ( "OFF" calc-keypad-off )
- X ( "0" ("0") calc-imaginary )
- X ( "." (".") calc-precision )
- X ( "PI" calc-pi )
- X ( "+" calc-plus calc-sqrt ) ) )
- )
- X
- (defvar calc-keypad-menus '( calc-keypad-math-menu
- X calc-keypad-funcs-menu
- X calc-keypad-binary-menu
- X calc-keypad-vector-menu
- X calc-keypad-modes-menu
- X calc-keypad-user-menu ) )
- X
- ;;; |----+----+----+----+----+----|
- ;;; |FLR |CEIL|RND |TRNC|CLN2|FLT |
- ;;; |----+----+----+----+----+----|
- ;;; | LN |EXP | |ABS |IDIV|MOD |
- ;;; |----+----+----+----+----+----|
- ;;; |SIN |COS |TAN |SQRT|y^x |1/x |
- X
- (defvar calc-keypad-math-menu
- X '( ( ( "FLR" calc-floor )
- X ( "CEIL" calc-ceiling )
- X ( "RND" calc-round )
- X ( "TRNC" calc-trunc )
- X ( "CLN2" (progn 2 calc-clean-num) )
- X ( "FLT" calc-float ) )
- X ( ( "LN" calc-ln )
- X ( "EXP" calc-exp )
- X ( "" nil )
- X ( "ABS" calc-abs )
- X ( "IDIV" calc-idiv )
- X ( "MOD" calc-mod ) )
- X ( ( "SIN" calc-sin )
- X ( "COS" calc-cos )
- X ( "TAN" calc-tan )
- X ( "SQRT" calc-sqrt )
- X ( "y^x" calc-power )
- X ( "1/x" calc-inv ) ) )
- )
- X
- ;;; |----+----+----+----+----+----|
- ;;; |IGAM|BETA|IBET|ERF |BESJ|BESY|
- ;;; |----+----+----+----+----+----|
- ;;; |IMAG|CONJ| RE |ATN2|RAND|RAGN|
- ;;; |----+----+----+----+----+----|
- ;;; |GCD |FACT|DFCT|BNOM|PERM|NXTP|
- X
- (defvar calc-keypad-funcs-menu
- X '( ( ( "IGAM" calc-inc-gamma )
- X ( "BETA" calc-beta )
- X ( "IBET" calc-inc-beta )
- X ( "ERF" calc-erf )
- X ( "BESJ" calc-bessel-J )
- X ( "BESY" calc-bessel-Y ) )
- X ( ( "IMAG" calc-imaginary )
- X ( "CONJ" calc-conj )
- X ( "RE" calc-re calc-im )
- X ( "ATN2" calc-arctan2 )
- X ( "RAND" calc-random )
- X ( "RAGN" calc-random-again ) )
- X ( ( "GCD" calc-gcd calc-lcm )
- X ( "FACT" calc-factorial calc-gamma )
- X ( "DFCT" calc-double-factorial )
- X ( "BNOM" calc-choose )
- X ( "PERM" calc-perm )
- X ( "NXTP" calc-next-prime calc-prev-prime ) ) )
- )
- X
- ;;; |----+----+----+----+----+----|
- ;;; |AND | OR |XOR |NOT |LSH |RSH |
- ;;; |----+----+----+----+----+----|
- ;;; |DEC |HEX |OCT |BIN |WSIZ|ARSH|
- ;;; |----+----+----+----+----+----|
- ;;; | A | B | C | D | E | F |
- X
- (defvar calc-keypad-binary-menu
- X '( ( ( "AND" calc-and calc-diff )
- X ( "OR" calc-or )
- X ( "XOR" calc-xor )
- X ( "NOT" calc-not calc-clip )
- X ( "LSH" calc-lshift-binary calc-rotate-binary )
- X ( "RSH" calc-rshift-binary ) )
- X ( ( "DEC" calc-decimal-radix )
- X ( "HEX" calc-hex-radix )
- X ( "OCT" calc-octal-radix )
- X ( "BIN" calc-binary-radix )
- X ( "WSIZ" (progn
- X (lambda (arg) (interactive "nWord size: ")
- X (setq prefix-arg arg))
- SHAR_EOF
- true || echo 'restore of calc-keypd.el failed'
- fi
- echo 'End of part 18'
- echo 'File calc-keypd.el is continued in part 19'
- echo 19 > _shar_seq_.tmp
- exit 0
- exit 0 # Just in case...
- --
- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM
- Sterling Software, IMD UUCP: uunet!sparky!kent
- Phone: (402) 291-8300 FAX: (402) 291-4362
- Please send comp.sources.misc-related mail to kent@uunet.uu.net.
-